package com.zyy.interpreter;


public class Client {
    public static void main(String[] args) {
        //a+b+c+d-e = 1+2+3+4-5 = 5
        //定义变量
        Variable a = new Variable("a");
        Variable b = new Variable("b");
        Variable c = new Variable("c");
        Variable d = new Variable("d");
        Variable e = new Variable("e");

        //给每个变量赋值
        Context context = new Context();
        context.assign(a, 1);
        context.assign(b, 2);
        context.assign(c, 3);
        context.assign(d, 4);
        context.assign(e, 5);

        //生成表达式  ((((a+b)+c)+d)-e)
        AbstractExpression expression = new Minus(new Plus(new Plus(new Plus(a, b), c), d), e);

        //expression.interpret(context) 解释表达式
        System.out.println(expression.toString() + "=" + expression.interpret(context));


    }
}
